#include "ThreadPool.hpp"
#include <memory>
#include <functional>
#include "Task.hpp"

//using func_t = std::function<void(std::string name)>; // 可调用对象的类型
using namespace LogMudule;
using namespace ThreadPoolModule;

//这里将来应该是外部来调用比如注册，
//我插入sql语句以及进行对应的函数判定，但是现在我是自己来插入
std::vector<std::string> Vector_SQL{
    "INSERT INTO user VALUES (11, '1251991122', '258979745')",
    "UPDATE user SET telephone = '1234567854' WHERE id = 3",
    "INSERT INTO user VALUES (12, '1217575122', '258575457')",
    "INSERT INTO user VALUES (13, '175893532', '25812424')",
    "INSERT INTO user VALUES (14, '13534322', '251114145')",
    "INSERT INTO user VALUES (15, '1243572443122', '272575745')",
    "INSERT INTO user VALUES (16, '126467574122', '257745')",
    "INSERT INTO user VALUES (17, '155522', '124245')",
    "DELETE FROM user WHERE id = 4"};

int main()
{
    ENABLE_CONSOLE_LOG();
    ThreadPool<Task>::getInstance()->Start();
    int cnt = 0;
    while (cnt <= 8)
    {
        //插入Task，此时插入的是一个一个类对象
        Task t(Vector_SQL[cnt]);
        ThreadPool<Task>::getInstance()->Equeue(t);
        LOG(LogLevel::DEBUG)<<"创建对象成功："<<t.str();
        cnt++;
    }
    ThreadPool<Task>::getInstance()->Stop();
    ThreadPool<Task>::getInstance()->Wait();
    /*std::shared_ptr<ThreadPool<func_t>> tp = std::make_shared<ThreadPool<func_t>>();
    tp->Start();

    int cnt = 10;
    while(cnt)
    {
        tp->Equeue(Push);
        cnt--;
        sleep(1);
    }

    tp->Wait();*/

    return 0;
}